@openclaw/tlon 2026.9.1-beta.1 → 2026.9.2

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 ssrfPolicyFromDangerouslyAllowPrivateNetwork, i as isBlockedHostnameOrIp, n as createDedupeCache, o as createLoggerBackedRuntime, r as fetchWithSsrFGuard, t as SsrFBlockedError } from "./runtime-api-BXVe40nS.js";
2
- import { t as tlonPlugin } from "./channel-BhqDxdrd.js";
2
+ import { t as tlonPlugin } from "./channel-Dx1jbpJ1.js";
3
3
  import { n as setTlonRuntime } from "./runtime-Ck3lNvST.js";
4
4
  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-CZ8OWBXt.js";
2
- import { d as resolveTlonAccount, f as formatTargetHint, g as resolveTlonOutboundTarget, h as parseTlonTarget, n as createTlonSetupWizardBase, o as tlonSetupContract, p as normalizeShip, u as listTlonAccountIds } from "./setup-core-QCmS9Gmh.js";
2
+ import { d as resolveTlonAccount, f as formatTargetHint, g as resolveTlonOutboundTarget, h as parseTlonTarget, n as createTlonSetupWizardBase, o as tlonSetupContract, p as normalizeShip, u as listTlonAccountIds } from "./setup-core-CYiZjoTI.js";
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";
@@ -24,6 +24,7 @@ const tlonCommonConfigFields = {
24
24
  name: z.string().optional(),
25
25
  enabled: z.boolean().optional(),
26
26
  configWrites: z.boolean().optional(),
27
+ mediaMaxMb: z.number().positive().optional(),
27
28
  ship: ShipSchema.optional(),
28
29
  url: z.string().optional(),
29
30
  code: z.string().optional(),
@@ -40,13 +41,14 @@ const tlonCommonConfigFields = {
40
41
  ownerShip: ShipSchema.optional()
41
42
  };
42
43
  const TlonAccountSchema = z.object({ ...tlonCommonConfigFields });
43
- const tlonChannelConfigSchema = buildChannelConfigSchema(z.object({
44
+ const TlonConfigSchema = z.object({
44
45
  ...tlonCommonConfigFields,
45
46
  historyLimit: z.number().int().min(0).optional(),
46
47
  authorization: TlonAuthorizationSchema.optional(),
47
48
  defaultAuthorizedShips: z.array(ShipSchema).optional(),
48
49
  accounts: z.record(z.string(), TlonAccountSchema).optional()
49
- }), { uiHints: createChannelConfigUiHints({
50
+ });
51
+ const tlonChannelConfigSchema = buildChannelConfigSchema(TlonConfigSchema, { uiHints: createChannelConfigUiHints({
50
52
  channelLabel: "Tlon",
51
53
  implicitMentions: true
52
54
  }) });
@@ -93,7 +95,7 @@ function resolveTlonOutboundSessionRoute(params) {
93
95
  //#endregion
94
96
  //#region extensions/tlon/src/channel.ts
95
97
  const TLON_CHANNEL_ID = "tlon";
96
- const loadTlonChannelRuntime = createLazyRuntimeModule(() => import("./channel.runtime-BiVAscnL.js"));
98
+ const loadTlonChannelRuntime = createLazyRuntimeModule(() => import("./channel.runtime-D5Rie0uM.js"));
97
99
  const tlonSetupWizardProxy = createTlonSetupWizardBase({
98
100
  resolveConfigured: async ({ cfg, accountId }) => await (await loadTlonChannelRuntime()).tlonSetupWizard.status.resolveConfigured({
99
101
  cfg,
@@ -1,2 +1,2 @@
1
- import { t as tlonPlugin } from "./channel-BhqDxdrd.js";
1
+ import { t as tlonPlugin } from "./channel-Dx1jbpJ1.js";
2
2
  export { tlonPlugin };
@@ -1,10 +1,9 @@
1
1
  import { n as createDedupeCache, o as createLoggerBackedRuntime } from "./runtime-api-BXVe40nS.js";
2
- import { c as normalizeUrbitHostname, d as resolveTlonAccount, f as formatTargetHint, g as resolveTlonOutboundTarget, h as parseTlonTarget, l as validateUrbitBaseUrl, m as parseChannelNest, p as normalizeShip } from "./setup-core-QCmS9Gmh.js";
2
+ import { c as normalizeUrbitHostname, d as resolveTlonAccount, f as formatTargetHint, h as parseTlonTarget, l as validateUrbitBaseUrl, m as parseChannelNest, p as normalizeShip } from "./setup-core-CYiZjoTI.js";
3
3
  import { t as getTlonRuntime } from "./runtime-Ck3lNvST.js";
4
- import { t as tlonSetupWizard } from "./setup-surface-UgXzT7Tg.js";
4
+ import { t as tlonSetupWizard } from "./setup-surface-35N3bJMh.js";
5
5
  import { fetchWithSsrFGuard, ssrfPolicyFromDangerouslyAllowPrivateNetwork } from "openclaw/plugin-sdk/ssrf-runtime";
6
6
  import { bindIngressLifecycleToReplyOptions, createChannelIngressError, createChannelIngressMonitor, createMessageReceiptFromOutboundResults, waitUntilAbort } from "openclaw/plugin-sdk/channel-outbound";
7
- import { chunkTextForOutbound } from "openclaw/plugin-sdk/text-chunking";
8
7
  import { expectDefined } from "openclaw/plugin-sdk/expect-runtime";
9
8
  import { asFiniteNumber, asNullableRecord, filterStringEntries, normalizeLowercaseStringOrEmpty, normalizeNullableString, readStringField, uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
10
9
  import crypto, { randomBytes, randomUUID } from "node:crypto";
@@ -27,6 +26,7 @@ import { extensionForMime } from "openclaw/plugin-sdk/media-mime";
27
26
  import { MAX_IMAGE_BYTES, readRemoteMediaBuffer, saveRemoteMedia } from "openclaw/plugin-sdk/media-runtime";
28
27
  import { PutObjectCommand, S3Client } from "@aws-sdk/client-s3";
29
28
  import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
29
+ import { bufferToBlobPart } from "openclaw/plugin-sdk/blob-runtime";
30
30
  //#region extensions/tlon/src/settings.ts
31
31
  /**
32
32
  * Settings Store integration for hot-reloading Tlon plugin config.
@@ -161,9 +161,7 @@ function applySettingsUpdate(current, key, value) {
161
161
  case "ownerShip":
162
162
  next.ownerShip = typeof value === "string" ? value : void 0;
163
163
  break;
164
- case "pendingApprovals":
165
- next.pendingApprovals = parsePendingApprovals(value);
166
- break;
164
+ case "pendingApprovals": next.pendingApprovals = parsePendingApprovals(value);
167
165
  }
168
166
  return next;
169
167
  }
@@ -286,8 +284,9 @@ var UrbitAuthError = class extends UrbitError {
286
284
  async function urbitFetch(params) {
287
285
  const validated = validateUrbitBaseUrl(params.baseUrl);
288
286
  if (!validated.ok) throw new UrbitUrlError(validated.error);
287
+ const url = new URL(params.path, validated.baseUrl).toString();
289
288
  const guarded = await fetchWithSsrFGuard({
290
- url: new URL(params.path, validated.baseUrl).toString(),
289
+ url,
291
290
  fetchImpl: params.fetchImpl,
292
291
  init: params.init,
293
292
  timeoutMs: params.timeoutMs,
@@ -308,7 +307,7 @@ async function urbitFetch(params) {
308
307
  }
309
308
  //#endregion
310
309
  //#region extensions/tlon/src/urbit/auth.ts
311
- const MAX_AUTH_BODY_DRAIN_BYTES = 64 * 1024;
310
+ const MAX_AUTH_BODY_DRAIN_BYTES = 65536;
312
311
  async function authenticate(url, code, options = {}) {
313
312
  const { response, release } = await urbitFetch({
314
313
  baseUrl: url,
@@ -727,7 +726,7 @@ function markdownToStory(markdown) {
727
726
  const paragraphLines = [];
728
727
  while (true) {
729
728
  const paragraphLine = lines.at(i);
730
- if (paragraphLine === void 0 || paragraphLine.trim() === "" || paragraphLine.startsWith("#") || paragraphLine.startsWith("```") || paragraphLine.startsWith("> ") || /^(-{3,}|\*{3,})$/.test(paragraphLine.trim())) break;
729
+ if (paragraphLine === void 0 || paragraphLine.trim() === "" || startsTopLevelStoryBlock(paragraphLine)) break;
731
730
  if (!preserveListText && MARKDOWN_LIST_ITEM_PATTERN.test(paragraphLine)) {
732
731
  const item = parseMarkdownListItem(paragraphLine);
733
732
  const candidate = parseListingBlock(lines, i);
@@ -888,7 +887,7 @@ async function putUrbitChannel(deps, params) {
888
887
  auditContext: params.auditContext
889
888
  });
890
889
  }
891
- const TLON_ERROR_BODY_LIMIT_BYTES = 16 * 1024;
890
+ const TLON_ERROR_BODY_LIMIT_BYTES = 16384;
892
891
  async function pokeUrbitChannel(deps, params) {
893
892
  const pokeId = Date.now();
894
893
  const { response, release } = await putUrbitChannel(deps, {
@@ -982,7 +981,7 @@ async function ensureUrbitChannelOpen(deps, params) {
982
981
  }
983
982
  //#endregion
984
983
  //#region extensions/tlon/src/urbit/sse-client.ts
985
- const MAX_SSE_PAYLOAD_BYTES = 16 * 1024 * 1024;
984
+ const MAX_SSE_PAYLOAD_BYTES = 16777216;
986
985
  function parseUrbitSsePayload(data) {
987
986
  if (Buffer.byteLength(data, "utf8") > MAX_SSE_PAYLOAD_BYTES) throw new Error("Tlon Urbit SSE payload exceeds 16 MiB limit");
988
987
  try {
@@ -1078,7 +1077,7 @@ var UrbitSSEClient = class {
1078
1077
  });
1079
1078
  try {
1080
1079
  if (!response.ok && response.status !== 204) {
1081
- const errorText = await readResponseTextLimited(response, 16 * 1024).catch(() => "");
1080
+ const errorText = await readResponseTextLimited(response, 16384).catch(() => "");
1082
1081
  throw new Error(`Subscribe failed: ${response.status}${errorText ? ` - ${errorText}` : ""}`);
1083
1082
  }
1084
1083
  } finally {
@@ -1205,8 +1204,8 @@ var UrbitSSEClient = class {
1205
1204
  let data = null;
1206
1205
  let eventId = null;
1207
1206
  for (const line of lines) {
1208
- if (line.startsWith("id: ")) eventId = parseUrbitSseEventId(line.slice(4));
1209
- if (line.startsWith("data: ")) data = line.slice(6);
1207
+ if (line.startsWith("id:")) eventId = parseUrbitSseEventId(line.slice(3).trim());
1208
+ if (line.startsWith("data:")) data = line.slice(5).trim();
1210
1209
  }
1211
1210
  if (!data) return;
1212
1211
  let parsed;
@@ -1720,31 +1719,29 @@ function createTlonApprovalRuntime(params) {
1720
1719
  }
1721
1720
  }
1722
1721
  break;
1723
- case "group":
1724
- if (approval.groupFlag) try {
1725
- await api.poke({
1726
- app: "groups",
1727
- mark: "group-join",
1728
- json: {
1729
- flag: approval.groupFlag,
1730
- "join-all": true
1722
+ case "group": if (approval.groupFlag) try {
1723
+ await api.poke({
1724
+ app: "groups",
1725
+ mark: "group-join",
1726
+ json: {
1727
+ flag: approval.groupFlag,
1728
+ "join-all": true
1729
+ }
1730
+ });
1731
+ runtime.log?.(`[tlon] Joined group ${approval.groupFlag} after approval`);
1732
+ setTimeout(() => {
1733
+ (async () => {
1734
+ try {
1735
+ const newCount = await refreshWatchedChannels();
1736
+ if (newCount > 0) runtime.log?.(`[tlon] Discovered ${newCount} new channel(s) after joining group`);
1737
+ } catch (err) {
1738
+ runtime.log?.(`[tlon] Channel discovery after group join failed: ${String(err)}`);
1731
1739
  }
1732
- });
1733
- runtime.log?.(`[tlon] Joined group ${approval.groupFlag} after approval`);
1734
- setTimeout(() => {
1735
- (async () => {
1736
- try {
1737
- const newCount = await refreshWatchedChannels();
1738
- if (newCount > 0) runtime.log?.(`[tlon] Discovered ${newCount} new channel(s) after joining group`);
1739
- } catch (err) {
1740
- runtime.log?.(`[tlon] Channel discovery after group join failed: ${String(err)}`);
1741
- }
1742
- })();
1743
- }, 2e3);
1744
- } catch (err) {
1745
- runtime.error?.(`[tlon] Failed to join group ${approval.groupFlag}: ${String(err)}`);
1746
- }
1747
- break;
1740
+ })();
1741
+ }, 2e3);
1742
+ } catch (err) {
1743
+ runtime.error?.(`[tlon] Failed to join group ${approval.groupFlag}: ${String(err)}`);
1744
+ }
1748
1745
  }
1749
1746
  await sendOwnerNotification(formatApprovalConfirmation(approval, "approve"));
1750
1747
  } else if (parsed.action === "block") {
@@ -2076,7 +2073,8 @@ function createTlonCitationResolver(params) {
2076
2073
  try {
2077
2074
  const scryPath = `/channels/v4/${cite.nest}/posts/post/${cite.postId}.json`;
2078
2075
  runtime.log?.(`[tlon] Fetching cited post: ${scryPath}`);
2079
- const essay = asNullableRecord(asNullableRecord(await api.scry(scryPath))?.essay);
2076
+ const data = asNullableRecord(await api.scry(scryPath));
2077
+ const essay = asNullableRecord(data?.essay);
2080
2078
  if (essay?.content) return extractMessageText(essay.content) || null;
2081
2079
  return null;
2082
2080
  } catch (err) {
@@ -2112,7 +2110,8 @@ async function fetchInitData(api, runtime) {
2112
2110
  const channels = [];
2113
2111
  const groups = asNullableRecord(initData?.groups);
2114
2112
  if (groups) for (const groupData of Object.values(groups)) {
2115
- const groupChannels = asNullableRecord(asNullableRecord(groupData)?.channels);
2113
+ const typedGroupData = asNullableRecord(groupData);
2114
+ const groupChannels = asNullableRecord(typedGroupData?.channels);
2116
2115
  if (groupChannels) {
2117
2116
  for (const channelNest of Object.keys(groupChannels)) if (channelNest.startsWith("chat/")) channels.push(channelNest);
2118
2117
  }
@@ -2162,15 +2161,7 @@ function createHistoryEntryFromMemo(params) {
2162
2161
  id: typeof seal?.id === "string" ? seal.id : typeof fallbackId === "string" ? fallbackId : void 0
2163
2162
  };
2164
2163
  }
2165
- const messageCache = /* @__PURE__ */ new Map();
2166
2164
  const MAX_CACHED_MESSAGES = 100;
2167
- function cacheMessage(channelNest, message) {
2168
- if (!messageCache.has(channelNest)) messageCache.set(channelNest, []);
2169
- const cache = messageCache.get(channelNest);
2170
- if (!cache) return;
2171
- cache.unshift(message);
2172
- if (cache.length > MAX_CACHED_MESSAGES) cache.pop();
2173
- }
2174
2165
  async function fetchChannelHistory(api, channelNest, count = 50, runtime) {
2175
2166
  try {
2176
2167
  const scryPath = `/channels/v4/${channelNest}/posts/newest/${count}/outline.json`;
@@ -2187,7 +2178,8 @@ async function fetchChannelHistory(api, channelNest, count = 50, runtime) {
2187
2178
  }
2188
2179
  const messages = posts.map((item) => {
2189
2180
  const itemRecord = asNullableRecord(item);
2190
- const replyPostSet = asNullableRecord(asNullableRecord(itemRecord?.["r-post"])?.set);
2181
+ const replyPost = asNullableRecord(itemRecord?.["r-post"]);
2182
+ const replyPostSet = asNullableRecord(replyPost?.set);
2191
2183
  const essay = asNullableRecord(itemRecord?.essay) ?? asNullableRecord(replyPostSet?.essay);
2192
2184
  const seal = asNullableRecord(itemRecord?.seal) ?? asNullableRecord(replyPostSet?.seal);
2193
2185
  return {
@@ -2204,14 +2196,25 @@ async function fetchChannelHistory(api, channelNest, count = 50, runtime) {
2204
2196
  return [];
2205
2197
  }
2206
2198
  }
2207
- async function getChannelHistory(api, channelNest, count = 50, runtime) {
2208
- const cache = messageCache.get(channelNest) ?? [];
2209
- if (cache.length >= count) {
2210
- runtime?.log?.(`[tlon] Using cached messages (${cache.length} available)`);
2211
- return cache.slice(0, count);
2212
- }
2213
- runtime?.log?.(`[tlon] Cache has ${cache.length} messages, need ${count}, fetching from scry...`);
2214
- return await fetchChannelHistory(api, channelNest, count, runtime);
2199
+ function createChannelHistoryCache() {
2200
+ const messageCache = /* @__PURE__ */ new Map();
2201
+ return {
2202
+ cacheMessage(channelNest, message) {
2203
+ const cache = messageCache.get(channelNest) ?? [];
2204
+ cache.unshift(message);
2205
+ if (cache.length > MAX_CACHED_MESSAGES) cache.pop();
2206
+ messageCache.set(channelNest, cache);
2207
+ },
2208
+ async getChannelHistory(api, channelNest, count = 50, runtime) {
2209
+ const cache = messageCache.get(channelNest) ?? [];
2210
+ if (cache.length >= count) {
2211
+ runtime?.log?.(`[tlon] Using cached messages (${cache.length} available)`);
2212
+ return cache.slice(0, count);
2213
+ }
2214
+ runtime?.log?.(`[tlon] Cache has ${cache.length} messages, need ${count}, fetching from scry...`);
2215
+ return await fetchChannelHistory(api, channelNest, count, runtime);
2216
+ }
2217
+ };
2215
2218
  }
2216
2219
  /**
2217
2220
  * Fetch thread/reply history for a specific parent post.
@@ -2239,7 +2242,8 @@ async function fetchThreadHistory(api, channelNest, parentId, count = 50, runtim
2239
2242
  }
2240
2243
  const messages = replies.map((item) => {
2241
2244
  const itemRecord = asNullableRecord(item);
2242
- const replySet = asNullableRecord(asNullableRecord(itemRecord?.["r-reply"])?.set);
2245
+ const replyRecord = asNullableRecord(itemRecord?.["r-reply"]);
2246
+ const replySet = asNullableRecord(replyRecord?.set);
2243
2247
  return createHistoryEntryFromMemo({
2244
2248
  memo: asNullableRecord(itemRecord?.memo) ?? asNullableRecord(replySet?.memo) ?? itemRecord,
2245
2249
  seal: asNullableRecord(itemRecord?.seal) ?? asNullableRecord(replySet?.seal),
@@ -2254,7 +2258,8 @@ async function fetchThreadHistory(api, channelNest, parentId, count = 50, runtim
2254
2258
  const altPath = `/channels/v4/${channelNest}/posts/post/id/${formatUd(parentId)}.json`;
2255
2259
  runtime?.log?.(`[tlon] Trying alternate path: ${altPath}`);
2256
2260
  const data = asNullableRecord(await api.scry(altPath));
2257
- const dataMeta = asNullableRecord(asNullableRecord(data?.seal)?.meta);
2261
+ const dataSeal = asNullableRecord(data?.seal);
2262
+ const dataMeta = asNullableRecord(dataSeal?.meta);
2258
2263
  const repliesValue = data?.replies;
2259
2264
  if (typeof dataMeta?.replyCount === "number" && dataMeta.replyCount > 0 && repliesValue) {
2260
2265
  const messages = (Array.isArray(repliesValue) ? repliesValue : Object.values(repliesValue)).map((reply) => {
@@ -2442,7 +2447,7 @@ function extractImageBlocks(content) {
2442
2447
  * Download a media file from URL to local storage.
2443
2448
  * Returns the local path where the file was saved.
2444
2449
  */
2445
- async function downloadMedia(url, mediaDir) {
2450
+ async function downloadMedia(url, mediaDir, maxBytes) {
2446
2451
  try {
2447
2452
  const parsedUrl = new URL(url);
2448
2453
  if (parsedUrl.protocol !== "http:" && parsedUrl.protocol !== "https:") {
@@ -2451,7 +2456,7 @@ async function downloadMedia(url, mediaDir) {
2451
2456
  }
2452
2457
  const fetchOptions = {
2453
2458
  url,
2454
- maxBytes: MAX_IMAGE_BYTES,
2459
+ maxBytes: Math.min(maxBytes ?? MAX_IMAGE_BYTES, MAX_IMAGE_BYTES),
2455
2460
  ...TLON_MEDIA_FETCH_TIMEOUTS,
2456
2461
  ssrfPolicy: void 0,
2457
2462
  requestInit: { method: "GET" }
@@ -2496,12 +2501,12 @@ function getExtensionFromUrl(url) {
2496
2501
  * Download all images from a message and return attachment metadata.
2497
2502
  * Format matches OpenClaw's expected attachment structure.
2498
2503
  */
2499
- async function downloadMessageImages(content, mediaDir) {
2504
+ async function downloadMessageImages(content, mediaDir, maxBytes) {
2500
2505
  const { images, unavailableCount: overCapCount } = extractImageBlocks(content);
2501
2506
  const attachments = [];
2502
2507
  let unavailableCount = overCapCount;
2503
2508
  for (const image of images) {
2504
- const downloaded = await downloadMedia(image.url, mediaDir);
2509
+ const downloaded = await downloadMedia(image.url, mediaDir, maxBytes);
2505
2510
  if (downloaded) attachments.push({
2506
2511
  path: downloaded.localPath,
2507
2512
  contentType: downloaded.contentType
@@ -2718,6 +2723,7 @@ async function monitorTlonProvider(opts = {}) {
2718
2723
  let pendingApprovals = [];
2719
2724
  let currentSettings = {};
2720
2725
  const participatedThreads = createParticipatedThreadTracker();
2726
+ const channelHistory = createChannelHistoryCache();
2721
2727
  const dmSendersBySession = /* @__PURE__ */ new Map();
2722
2728
  let sharedSessionWarningSent = false;
2723
2729
  try {
@@ -2783,7 +2789,8 @@ async function monitorTlonProvider(opts = {}) {
2783
2789
  * Returns empty string if whom doesn't contain a valid patp-like value.
2784
2790
  */
2785
2791
  function extractDmPartnerShip(whom) {
2786
- const normalized = normalizeShip(typeof whom === "string" ? whom : whom && typeof whom === "object" && "ship" in whom && typeof whom.ship === "string" ? whom.ship : "");
2792
+ const raw = typeof whom === "string" ? whom : whom && typeof whom === "object" && "ship" in whom && typeof whom.ship === "string" ? whom.ship : "";
2793
+ const normalized = normalizeShip(raw);
2787
2794
  return /^~?[a-z-]+$/i.test(normalized) ? normalized : "";
2788
2795
  }
2789
2796
  const processMessage = async (params) => {
@@ -2793,7 +2800,7 @@ async function monitorTlonProvider(opts = {}) {
2793
2800
  let attachments = [];
2794
2801
  let unavailableMediaCount = 0;
2795
2802
  if (messageContent) try {
2796
- ({attachments, unavailableCount: unavailableMediaCount} = await downloadMessageImages(messageContent));
2803
+ ({attachments, unavailableCount: unavailableMediaCount} = await downloadMessageImages(messageContent, void 0, account.mediaMaxBytes));
2797
2804
  if (attachments.length > 0) runtime.log?.(`[tlon] Downloaded ${attachments.length} image(s) from message`);
2798
2805
  } catch (error) {
2799
2806
  runtime.log?.(`[tlon] Failed to download images: ${formatErrorMessage(error)}`);
@@ -2809,7 +2816,7 @@ async function monitorTlonProvider(opts = {}) {
2809
2816
  runtime?.log?.(`[tlon] Could not fetch thread context: ${formatErrorMessage(error)}`);
2810
2817
  }
2811
2818
  if (isGroup && groupChannel && isSummarizationRequest(messageText)) try {
2812
- const history = await getChannelHistory(api, groupChannel, 50, runtime);
2819
+ const history = await channelHistory.getChannelHistory(api, groupChannel, 50, runtime);
2813
2820
  if (history.length === 0) {
2814
2821
  const noHistoryMsg = "I couldn't fetch any messages for this channel. It might be empty or there might be a permissions issue.";
2815
2822
  if (isGroup) {
@@ -3146,7 +3153,8 @@ async function monitorTlonProvider(opts = {}) {
3146
3153
  const rPost = asNullableRecord(post?.["r-post"]);
3147
3154
  const set = asNullableRecord(rPost?.set);
3148
3155
  const reply = asNullableRecord(rPost?.reply);
3149
- const replySet = asNullableRecord(asNullableRecord(reply?.["r-reply"])?.set);
3156
+ const replyPayload = asNullableRecord(reply?.["r-reply"]);
3157
+ const replySet = asNullableRecord(replyPayload?.set);
3150
3158
  const essay = asNullableRecord(set?.essay);
3151
3159
  const memo = asNullableRecord(replySet?.memo);
3152
3160
  if (!essay && !memo) return;
@@ -3161,7 +3169,7 @@ async function monitorTlonProvider(opts = {}) {
3161
3169
  if (!rawText.trim()) return;
3162
3170
  const contentBody = content.content;
3163
3171
  const sentAt = asFiniteNumber(content?.sent) ?? Date.now();
3164
- cacheMessage(nest, {
3172
+ channelHistory.cacheMessage(nest, {
3165
3173
  author: senderShip,
3166
3174
  content: rawText,
3167
3175
  timestamp: sentAt,
@@ -3441,7 +3449,9 @@ async function monitorTlonProvider(opts = {}) {
3441
3449
  try {
3442
3450
  const eventRecord = asNullableRecord(event);
3443
3451
  if (eventRecord?.self) {
3444
- const nickname = asNullableRecord(asNullableRecord(asNullableRecord(eventRecord.self)?.contact)?.nickname);
3452
+ const selfUpdate = asNullableRecord(eventRecord.self);
3453
+ const contact = asNullableRecord(selfUpdate?.contact);
3454
+ const nickname = asNullableRecord(contact?.nickname);
3445
3455
  if (nickname && "value" in nickname) {
3446
3456
  const newNickname = readStringField(nickname, "value") ?? null;
3447
3457
  if (newNickname !== botNickname) {
@@ -3633,7 +3643,7 @@ async function monitorTlonProvider(opts = {}) {
3633
3643
  runtime.error?.(`[tlon] Channel refresh error: ${formatErrorMessage(error)}`);
3634
3644
  }
3635
3645
  })();
3636
- }, 120 * 1e3);
3646
+ }, 12e4);
3637
3647
  await waitUntilAbort(opts.abortSignal, () => {
3638
3648
  clearInterval(pollInterval);
3639
3649
  });
@@ -3651,7 +3661,7 @@ async function monitorTlonProvider(opts = {}) {
3651
3661
  //#region extensions/tlon/src/tlon-api.ts
3652
3662
  const MEMEX_BASE_URL = "https://memex.tlon.network";
3653
3663
  /** Max bytes to read from the Memex upload JSON response. */
3654
- const MEMEX_UPLOAD_RESPONSE_MAX_BYTES = 64 * 1024;
3664
+ const MEMEX_UPLOAD_RESPONSE_MAX_BYTES = 65536;
3655
3665
  /** Total deadline for the Memex upload URL lookup, including DNS and response reading. */
3656
3666
  const TLON_MEMEX_UPLOAD_URL_TIMEOUT_MS = 3e4;
3657
3667
  /** Total deadline for Memex and custom S3 PUTs, including DNS and the full upload. */
@@ -3851,13 +3861,14 @@ async function uploadFile(params) {
3851
3861
  "Content-Type": contentType,
3852
3862
  "x-amz-acl": "public-read"
3853
3863
  };
3854
- const signedUrl = await getSignedUrl(client, new PutObjectCommand({
3864
+ const command = new PutObjectCommand({
3855
3865
  Bucket: storageConfig.currentBucket,
3856
3866
  Key: fileKey,
3857
3867
  ContentType: headers["Content-Type"],
3858
3868
  CacheControl: headers["Cache-Control"],
3859
3869
  ACL: "public-read"
3860
- }), { expiresIn: 3600 });
3870
+ });
3871
+ const signedUrl = await getSignedUrl(client, command, { expiresIn: 3600 });
3861
3872
  let guarded;
3862
3873
  try {
3863
3874
  guarded = await fetchWithSsrFGuard({
@@ -3886,31 +3897,31 @@ async function uploadFile(params) {
3886
3897
  */
3887
3898
  /**
3888
3899
  * Fetch an image from a URL and upload it to Tlon storage.
3889
- * Returns the uploaded URL, or falls back to the original URL on error.
3900
+ * Falls back to the original URL on error, but only after a bounded download when a cap is set.
3890
3901
  *
3891
3902
  * Note: configureClient must be called before using this function.
3892
3903
  */
3893
- async function uploadImageFromUrl(imageUrl) {
3904
+ async function uploadImageFromUrl(imageUrl, maxBytes) {
3905
+ let sourceSizeVerified = false;
3894
3906
  try {
3895
3907
  const url = new URL(imageUrl);
3896
- if (url.protocol !== "http:" && url.protocol !== "https:") {
3897
- console.warn(`[tlon] Rejected non-http(s) URL: ${imageUrl}`);
3898
- return imageUrl;
3899
- }
3908
+ if (url.protocol !== "http:" && url.protocol !== "https:") throw new Error("Tlon image URL must use HTTP or HTTPS");
3900
3909
  const fetched = await readRemoteMediaBuffer({
3901
3910
  url: imageUrl,
3902
- maxBytes: MAX_IMAGE_BYTES,
3911
+ maxBytes: Math.min(maxBytes ?? MAX_IMAGE_BYTES, MAX_IMAGE_BYTES),
3903
3912
  ...TLON_MEDIA_FETCH_TIMEOUTS,
3904
3913
  ssrfPolicy: void 0,
3905
3914
  requestInit: { method: "GET" }
3906
3915
  });
3916
+ sourceSizeVerified = true;
3907
3917
  const contentType = fetched.contentType || "image/png";
3908
3918
  return (await uploadFile({
3909
- blob: new Blob([new Uint8Array(fetched.buffer)], { type: contentType }),
3919
+ blob: new Blob([bufferToBlobPart(fetched.buffer)], { type: contentType }),
3910
3920
  fileName: new URL(imageUrl).pathname.split("/").pop() || `upload-${Date.now()}.png`,
3911
3921
  contentType
3912
3922
  })).url;
3913
3923
  } catch (err) {
3924
+ if (maxBytes !== void 0 && !sourceSizeVerified) throw err;
3914
3925
  console.warn(`[tlon] Failed to upload image, using original URL: ${String(err)}`);
3915
3926
  return imageUrl;
3916
3927
  }
@@ -3922,43 +3933,40 @@ async function createHttpPokeApi(params) {
3922
3933
  const cookie = await authenticate(params.url, params.code, { ssrfPolicy });
3923
3934
  const channelPath = `/~/channel/${`${Math.floor(Date.now() / 1e3)}-${crypto.randomUUID()}`}`;
3924
3935
  const shipName = params.ship.replace(/^~/, "");
3925
- return {
3926
- poke: async (pokeParams) => {
3927
- const pokeId = Date.now();
3928
- const pokeData = {
3929
- id: pokeId,
3930
- action: "poke",
3931
- ship: shipName,
3932
- app: pokeParams.app,
3933
- mark: pokeParams.mark,
3934
- json: pokeParams.json
3935
- };
3936
- const { response, release } = await urbitFetch({
3937
- baseUrl: params.url,
3938
- path: channelPath,
3939
- init: {
3940
- method: "PUT",
3941
- headers: {
3942
- "Content-Type": "application/json",
3943
- Cookie: expectDefined(cookie.split(";").at(0), "cookie first segment")
3944
- },
3945
- body: JSON.stringify([pokeData])
3936
+ return { poke: async (pokeParams) => {
3937
+ const pokeId = Date.now();
3938
+ const pokeData = {
3939
+ id: pokeId,
3940
+ action: "poke",
3941
+ ship: shipName,
3942
+ app: pokeParams.app,
3943
+ mark: pokeParams.mark,
3944
+ json: pokeParams.json
3945
+ };
3946
+ const { response, release } = await urbitFetch({
3947
+ baseUrl: params.url,
3948
+ path: channelPath,
3949
+ init: {
3950
+ method: "PUT",
3951
+ headers: {
3952
+ "Content-Type": "application/json",
3953
+ Cookie: expectDefined(cookie.split(";").at(0), "cookie first segment")
3946
3954
  },
3947
- ssrfPolicy,
3948
- auditContext: "tlon-poke"
3949
- });
3950
- try {
3951
- if (!response.ok && response.status !== 204) {
3952
- const errorText = await readResponseTextLimited(response, 16 * 1024);
3953
- throw new Error(`Poke failed: ${response.status} - ${errorText}`);
3954
- }
3955
- return pokeId;
3956
- } finally {
3957
- await release();
3955
+ body: JSON.stringify([pokeData])
3956
+ },
3957
+ ssrfPolicy,
3958
+ auditContext: "tlon-poke"
3959
+ });
3960
+ try {
3961
+ if (!response.ok && response.status !== 204) {
3962
+ const errorText = await readResponseTextLimited(response, 16384);
3963
+ throw new Error(`Poke failed: ${response.status} - ${errorText}`);
3958
3964
  }
3959
- },
3960
- delete: async () => {}
3961
- };
3965
+ return pokeId;
3966
+ } finally {
3967
+ await release();
3968
+ }
3969
+ } };
3962
3970
  }
3963
3971
  function resolveOutboundContext(params) {
3964
3972
  const account = resolveTlonAccount(params.cfg, params.accountId ?? void 0);
@@ -3973,64 +3981,16 @@ function resolveOutboundContext(params) {
3973
3981
  function resolveReplyId(replyToId, threadId) {
3974
3982
  return replyToId ?? threadId ? String(replyToId ?? threadId) : void 0;
3975
3983
  }
3976
- async function withHttpPokeAccountApi(account, run) {
3977
- const api = await createHttpPokeApi({
3978
- url: account.url,
3979
- ship: account.ship,
3980
- code: account.code,
3981
- dangerouslyAllowPrivateNetwork: account.dangerouslyAllowPrivateNetwork ?? void 0
3984
+ async function sendTlonOutbound(params, kind) {
3985
+ const { cfg, to, text, accountId, replyToId, threadId } = params;
3986
+ const { account, parsed } = resolveOutboundContext({
3987
+ cfg,
3988
+ accountId,
3989
+ to
3982
3990
  });
3983
- try {
3984
- return await run(api);
3985
- } finally {
3986
- try {
3987
- await api.delete();
3988
- } catch {}
3989
- }
3990
- }
3991
- const tlonRuntimeOutbound = {
3992
- deliveryMode: "direct",
3993
- chunker: chunkTextForOutbound,
3994
- chunkerMode: "markdown",
3995
- textChunkLimit: 1e4,
3996
- resolveTarget: ({ to }) => resolveTlonOutboundTarget(to),
3997
- deliveryCapabilities: { durableFinal: {
3998
- text: true,
3999
- media: true,
4000
- replyTo: true,
4001
- thread: true,
4002
- messageSendingHooks: true
4003
- } },
4004
- sendText: async ({ cfg, to, text, accountId, replyToId, threadId }) => {
4005
- const { account, parsed } = resolveOutboundContext({
4006
- cfg,
4007
- accountId,
4008
- to
4009
- });
4010
- return withHttpPokeAccountApi(account, async (api) => {
4011
- const fromShip = normalizeShip(account.ship);
4012
- if (parsed.kind === "dm") return await sendDm({
4013
- api,
4014
- fromShip,
4015
- toShip: parsed.ship,
4016
- text
4017
- });
4018
- return await sendGroupMessage({
4019
- api,
4020
- fromShip,
4021
- hostShip: parsed.hostShip,
4022
- channelName: parsed.channelName,
4023
- text,
4024
- replyToId: resolveReplyId(replyToId, threadId)
4025
- });
4026
- });
4027
- },
4028
- sendMedia: async ({ cfg, to, text, mediaUrl, accountId, replyToId, threadId }) => {
4029
- const { account, parsed } = resolveOutboundContext({
4030
- cfg,
4031
- accountId,
4032
- to
4033
- });
3991
+ let uploadedUrl;
3992
+ if (kind === "media") {
3993
+ const { mediaUrl } = params;
4034
3994
  configureClient({
4035
3995
  shipUrl: account.url,
4036
3996
  shipName: account.ship.replace(/^~/, ""),
@@ -4038,28 +3998,36 @@ const tlonRuntimeOutbound = {
4038
3998
  getCode: async () => account.code,
4039
3999
  dangerouslyAllowPrivateNetwork: account.dangerouslyAllowPrivateNetwork ?? void 0
4040
4000
  });
4041
- const uploadedUrl = mediaUrl ? await uploadImageFromUrl(mediaUrl) : void 0;
4042
- return withHttpPokeAccountApi(account, async (api) => {
4043
- const fromShip = normalizeShip(account.ship);
4044
- const story = buildMediaStory(text, uploadedUrl);
4045
- if (parsed.kind === "dm") return await sendDmWithStory({
4046
- api,
4047
- fromShip,
4048
- toShip: parsed.ship,
4049
- story,
4050
- kind: "media"
4051
- });
4052
- return await sendGroupMessageWithStory({
4053
- api,
4054
- fromShip,
4055
- hostShip: parsed.hostShip,
4056
- channelName: parsed.channelName,
4057
- story,
4058
- replyToId: resolveReplyId(replyToId, threadId),
4059
- kind: "media"
4060
- });
4061
- });
4001
+ uploadedUrl = mediaUrl ? await uploadImageFromUrl(mediaUrl, account.mediaMaxBytes) : void 0;
4062
4002
  }
4003
+ const api = await createHttpPokeApi({
4004
+ url: account.url,
4005
+ ship: account.ship,
4006
+ code: account.code,
4007
+ dangerouslyAllowPrivateNetwork: account.dangerouslyAllowPrivateNetwork ?? void 0
4008
+ });
4009
+ const fromShip = normalizeShip(account.ship);
4010
+ const story = kind === "media" ? buildMediaStory(text, uploadedUrl) : markdownToStory(text);
4011
+ if (parsed.kind === "dm") return await sendDmWithStory({
4012
+ api,
4013
+ fromShip,
4014
+ toShip: parsed.ship,
4015
+ story,
4016
+ kind
4017
+ });
4018
+ return await sendGroupMessageWithStory({
4019
+ api,
4020
+ fromShip,
4021
+ hostShip: parsed.hostShip,
4022
+ channelName: parsed.channelName,
4023
+ story,
4024
+ replyToId: resolveReplyId(replyToId, threadId),
4025
+ kind
4026
+ });
4027
+ }
4028
+ const tlonRuntimeOutbound = {
4029
+ sendText: (params) => sendTlonOutbound(params, "text"),
4030
+ sendMedia: (params) => sendTlonOutbound(params, "media")
4063
4031
  };
4064
4032
  async function probeTlonAccount(account, timeoutMs) {
4065
4033
  return await runChannelProbe(timeoutMs, async () => {
package/dist/setup-api.js CHANGED
@@ -1,3 +1,3 @@
1
- import { a as tlonSetupAdapter } from "./setup-core-QCmS9Gmh.js";
2
- import { t as tlonSetupWizard } from "./setup-surface-UgXzT7Tg.js";
1
+ import { a as tlonSetupAdapter } from "./setup-core-CYiZjoTI.js";
2
+ import { t as tlonSetupWizard } from "./setup-surface-35N3bJMh.js";
3
3
  export { tlonSetupAdapter, tlonSetupWizard };
@@ -1,5 +1,5 @@
1
1
  import { hasLegacyFlatAllowPrivateNetworkAlias, isBlockedHostnameOrIp, isPrivateNetworkOptInEnabled } from "openclaw/plugin-sdk/ssrf-runtime";
2
- import { createAccountListHelpers } from "openclaw/plugin-sdk/account-helpers";
2
+ import { createAccountListHelpers, resolveChannelMediaMaxBytes } from "openclaw/plugin-sdk/account-helpers";
3
3
  import { expectDefined } from "openclaw/plugin-sdk/expect-runtime";
4
4
  import { defineChannelSetupContract } from "openclaw/plugin-sdk/channel-setup";
5
5
  import { DEFAULT_ACCOUNT_ID, createSetupInputPresenceValidator, createSetupTranslator, formatDocsLink, normalizeAccountId, patchScopedAccountConfig, prepareScopedSetupConfig } from "openclaw/plugin-sdk/setup";
@@ -158,6 +158,11 @@ function resolveTlonAccount(cfg, accountId) {
158
158
  name: merged.name ?? null,
159
159
  enabled: merged.enabled !== false,
160
160
  configured,
161
+ mediaMaxBytes: resolveChannelMediaMaxBytes({
162
+ cfg,
163
+ accountId: resolvedAccountId,
164
+ resolveChannelLimitMb: () => merged.mediaMaxMb
165
+ }),
161
166
  ship,
162
167
  url,
163
168
  code,
@@ -1,4 +1,4 @@
1
- import { d as resolveTlonAccount, i as resolveTlonSetupStatusLines, l as validateUrbitBaseUrl, n as createTlonSetupWizardBase, p as normalizeShip, r as resolveTlonSetupConfigured, s as isBlockedUrbitHostname, t as applyTlonSetupConfig } from "./setup-core-QCmS9Gmh.js";
1
+ import { d as resolveTlonAccount, i as resolveTlonSetupStatusLines, l as validateUrbitBaseUrl, n as createTlonSetupWizardBase, p as normalizeShip, r as resolveTlonSetupConfigured, s as isBlockedUrbitHostname, t as applyTlonSetupConfig } from "./setup-core-CYiZjoTI.js";
2
2
  import { normalizeStringEntries } from "openclaw/plugin-sdk/string-coerce-runtime";
3
3
  import { createSetupTranslator } from "openclaw/plugin-sdk/setup-runtime";
4
4
  //#region extensions/tlon/src/setup-surface.ts
@@ -34,6 +34,10 @@
34
34
  "configWrites": {
35
35
  "type": "boolean"
36
36
  },
37
+ "mediaMaxMb": {
38
+ "type": "number",
39
+ "exclusiveMinimum": 0
40
+ },
37
41
  "ship": {
38
42
  "type": "string",
39
43
  "minLength": 1
@@ -169,6 +173,10 @@
169
173
  "configWrites": {
170
174
  "type": "boolean"
171
175
  },
176
+ "mediaMaxMb": {
177
+ "type": "number",
178
+ "exclusiveMinimum": 0
179
+ },
172
180
  "ship": {
173
181
  "type": "string",
174
182
  "minLength": 1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/tlon",
3
- "version": "2026.9.1-beta.1",
3
+ "version": "2026.9.2",
4
4
  "description": "OpenClaw Tlon/Urbit channel plugin for chat workflows.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -8,8 +8,8 @@
8
8
  },
9
9
  "type": "module",
10
10
  "dependencies": {
11
- "@aws-sdk/client-s3": "3.1113.0",
12
- "@aws-sdk/s3-request-presigner": "3.1113.0",
11
+ "@aws-sdk/client-s3": "3.1117.0",
12
+ "@aws-sdk/s3-request-presigner": "3.1117.0",
13
13
  "@tloncorp/tlon-skill": "0.5.0",
14
14
  "@urbit/aura": "3.0.0",
15
15
  "zod": "4.4.3"
@@ -19,7 +19,7 @@
19
19
  "openclaw": "workspace:*"
20
20
  },
21
21
  "peerDependencies": {
22
- "openclaw": ">=2026.9.1-beta.1"
22
+ "openclaw": ">=2026.9.2"
23
23
  },
24
24
  "peerDependenciesMeta": {
25
25
  "openclaw": {
@@ -120,10 +120,10 @@
120
120
  "minHostVersion": ">=2026.4.10"
121
121
  },
122
122
  "compat": {
123
- "pluginApi": ">=2026.9.1-beta.1"
123
+ "pluginApi": ">=2026.9.2"
124
124
  },
125
125
  "build": {
126
- "openclawVersion": "2026.9.1-beta.1"
126
+ "openclawVersion": "2026.9.2"
127
127
  },
128
128
  "release": {
129
129
  "bundleRuntimeDependencies": false,