@openclaw/tlon 2026.9.1-beta.1 → 2026.9.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 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-kxGvWAPU.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-C-K7iVvC.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-kxGvWAPU.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
  }
@@ -2187,7 +2186,8 @@ async function fetchChannelHistory(api, channelNest, count = 50, runtime) {
2187
2186
  }
2188
2187
  const messages = posts.map((item) => {
2189
2188
  const itemRecord = asNullableRecord(item);
2190
- const replyPostSet = asNullableRecord(asNullableRecord(itemRecord?.["r-post"])?.set);
2189
+ const replyPost = asNullableRecord(itemRecord?.["r-post"]);
2190
+ const replyPostSet = asNullableRecord(replyPost?.set);
2191
2191
  const essay = asNullableRecord(itemRecord?.essay) ?? asNullableRecord(replyPostSet?.essay);
2192
2192
  const seal = asNullableRecord(itemRecord?.seal) ?? asNullableRecord(replyPostSet?.seal);
2193
2193
  return {
@@ -2239,7 +2239,8 @@ async function fetchThreadHistory(api, channelNest, parentId, count = 50, runtim
2239
2239
  }
2240
2240
  const messages = replies.map((item) => {
2241
2241
  const itemRecord = asNullableRecord(item);
2242
- const replySet = asNullableRecord(asNullableRecord(itemRecord?.["r-reply"])?.set);
2242
+ const replyRecord = asNullableRecord(itemRecord?.["r-reply"]);
2243
+ const replySet = asNullableRecord(replyRecord?.set);
2243
2244
  return createHistoryEntryFromMemo({
2244
2245
  memo: asNullableRecord(itemRecord?.memo) ?? asNullableRecord(replySet?.memo) ?? itemRecord,
2245
2246
  seal: asNullableRecord(itemRecord?.seal) ?? asNullableRecord(replySet?.seal),
@@ -2254,7 +2255,8 @@ async function fetchThreadHistory(api, channelNest, parentId, count = 50, runtim
2254
2255
  const altPath = `/channels/v4/${channelNest}/posts/post/id/${formatUd(parentId)}.json`;
2255
2256
  runtime?.log?.(`[tlon] Trying alternate path: ${altPath}`);
2256
2257
  const data = asNullableRecord(await api.scry(altPath));
2257
- const dataMeta = asNullableRecord(asNullableRecord(data?.seal)?.meta);
2258
+ const dataSeal = asNullableRecord(data?.seal);
2259
+ const dataMeta = asNullableRecord(dataSeal?.meta);
2258
2260
  const repliesValue = data?.replies;
2259
2261
  if (typeof dataMeta?.replyCount === "number" && dataMeta.replyCount > 0 && repliesValue) {
2260
2262
  const messages = (Array.isArray(repliesValue) ? repliesValue : Object.values(repliesValue)).map((reply) => {
@@ -2442,7 +2444,7 @@ function extractImageBlocks(content) {
2442
2444
  * Download a media file from URL to local storage.
2443
2445
  * Returns the local path where the file was saved.
2444
2446
  */
2445
- async function downloadMedia(url, mediaDir) {
2447
+ async function downloadMedia(url, mediaDir, maxBytes) {
2446
2448
  try {
2447
2449
  const parsedUrl = new URL(url);
2448
2450
  if (parsedUrl.protocol !== "http:" && parsedUrl.protocol !== "https:") {
@@ -2451,7 +2453,7 @@ async function downloadMedia(url, mediaDir) {
2451
2453
  }
2452
2454
  const fetchOptions = {
2453
2455
  url,
2454
- maxBytes: MAX_IMAGE_BYTES,
2456
+ maxBytes: Math.min(maxBytes ?? MAX_IMAGE_BYTES, MAX_IMAGE_BYTES),
2455
2457
  ...TLON_MEDIA_FETCH_TIMEOUTS,
2456
2458
  ssrfPolicy: void 0,
2457
2459
  requestInit: { method: "GET" }
@@ -2496,12 +2498,12 @@ function getExtensionFromUrl(url) {
2496
2498
  * Download all images from a message and return attachment metadata.
2497
2499
  * Format matches OpenClaw's expected attachment structure.
2498
2500
  */
2499
- async function downloadMessageImages(content, mediaDir) {
2501
+ async function downloadMessageImages(content, mediaDir, maxBytes) {
2500
2502
  const { images, unavailableCount: overCapCount } = extractImageBlocks(content);
2501
2503
  const attachments = [];
2502
2504
  let unavailableCount = overCapCount;
2503
2505
  for (const image of images) {
2504
- const downloaded = await downloadMedia(image.url, mediaDir);
2506
+ const downloaded = await downloadMedia(image.url, mediaDir, maxBytes);
2505
2507
  if (downloaded) attachments.push({
2506
2508
  path: downloaded.localPath,
2507
2509
  contentType: downloaded.contentType
@@ -2783,7 +2785,8 @@ async function monitorTlonProvider(opts = {}) {
2783
2785
  * Returns empty string if whom doesn't contain a valid patp-like value.
2784
2786
  */
2785
2787
  function extractDmPartnerShip(whom) {
2786
- const normalized = normalizeShip(typeof whom === "string" ? whom : whom && typeof whom === "object" && "ship" in whom && typeof whom.ship === "string" ? whom.ship : "");
2788
+ const raw = typeof whom === "string" ? whom : whom && typeof whom === "object" && "ship" in whom && typeof whom.ship === "string" ? whom.ship : "";
2789
+ const normalized = normalizeShip(raw);
2787
2790
  return /^~?[a-z-]+$/i.test(normalized) ? normalized : "";
2788
2791
  }
2789
2792
  const processMessage = async (params) => {
@@ -2793,7 +2796,7 @@ async function monitorTlonProvider(opts = {}) {
2793
2796
  let attachments = [];
2794
2797
  let unavailableMediaCount = 0;
2795
2798
  if (messageContent) try {
2796
- ({attachments, unavailableCount: unavailableMediaCount} = await downloadMessageImages(messageContent));
2799
+ ({attachments, unavailableCount: unavailableMediaCount} = await downloadMessageImages(messageContent, void 0, account.mediaMaxBytes));
2797
2800
  if (attachments.length > 0) runtime.log?.(`[tlon] Downloaded ${attachments.length} image(s) from message`);
2798
2801
  } catch (error) {
2799
2802
  runtime.log?.(`[tlon] Failed to download images: ${formatErrorMessage(error)}`);
@@ -3146,7 +3149,8 @@ async function monitorTlonProvider(opts = {}) {
3146
3149
  const rPost = asNullableRecord(post?.["r-post"]);
3147
3150
  const set = asNullableRecord(rPost?.set);
3148
3151
  const reply = asNullableRecord(rPost?.reply);
3149
- const replySet = asNullableRecord(asNullableRecord(reply?.["r-reply"])?.set);
3152
+ const replyPayload = asNullableRecord(reply?.["r-reply"]);
3153
+ const replySet = asNullableRecord(replyPayload?.set);
3150
3154
  const essay = asNullableRecord(set?.essay);
3151
3155
  const memo = asNullableRecord(replySet?.memo);
3152
3156
  if (!essay && !memo) return;
@@ -3441,7 +3445,9 @@ async function monitorTlonProvider(opts = {}) {
3441
3445
  try {
3442
3446
  const eventRecord = asNullableRecord(event);
3443
3447
  if (eventRecord?.self) {
3444
- const nickname = asNullableRecord(asNullableRecord(asNullableRecord(eventRecord.self)?.contact)?.nickname);
3448
+ const selfUpdate = asNullableRecord(eventRecord.self);
3449
+ const contact = asNullableRecord(selfUpdate?.contact);
3450
+ const nickname = asNullableRecord(contact?.nickname);
3445
3451
  if (nickname && "value" in nickname) {
3446
3452
  const newNickname = readStringField(nickname, "value") ?? null;
3447
3453
  if (newNickname !== botNickname) {
@@ -3633,7 +3639,7 @@ async function monitorTlonProvider(opts = {}) {
3633
3639
  runtime.error?.(`[tlon] Channel refresh error: ${formatErrorMessage(error)}`);
3634
3640
  }
3635
3641
  })();
3636
- }, 120 * 1e3);
3642
+ }, 12e4);
3637
3643
  await waitUntilAbort(opts.abortSignal, () => {
3638
3644
  clearInterval(pollInterval);
3639
3645
  });
@@ -3651,7 +3657,7 @@ async function monitorTlonProvider(opts = {}) {
3651
3657
  //#region extensions/tlon/src/tlon-api.ts
3652
3658
  const MEMEX_BASE_URL = "https://memex.tlon.network";
3653
3659
  /** Max bytes to read from the Memex upload JSON response. */
3654
- const MEMEX_UPLOAD_RESPONSE_MAX_BYTES = 64 * 1024;
3660
+ const MEMEX_UPLOAD_RESPONSE_MAX_BYTES = 65536;
3655
3661
  /** Total deadline for the Memex upload URL lookup, including DNS and response reading. */
3656
3662
  const TLON_MEMEX_UPLOAD_URL_TIMEOUT_MS = 3e4;
3657
3663
  /** Total deadline for Memex and custom S3 PUTs, including DNS and the full upload. */
@@ -3851,13 +3857,14 @@ async function uploadFile(params) {
3851
3857
  "Content-Type": contentType,
3852
3858
  "x-amz-acl": "public-read"
3853
3859
  };
3854
- const signedUrl = await getSignedUrl(client, new PutObjectCommand({
3860
+ const command = new PutObjectCommand({
3855
3861
  Bucket: storageConfig.currentBucket,
3856
3862
  Key: fileKey,
3857
3863
  ContentType: headers["Content-Type"],
3858
3864
  CacheControl: headers["Cache-Control"],
3859
3865
  ACL: "public-read"
3860
- }), { expiresIn: 3600 });
3866
+ });
3867
+ const signedUrl = await getSignedUrl(client, command, { expiresIn: 3600 });
3861
3868
  let guarded;
3862
3869
  try {
3863
3870
  guarded = await fetchWithSsrFGuard({
@@ -3886,31 +3893,31 @@ async function uploadFile(params) {
3886
3893
  */
3887
3894
  /**
3888
3895
  * 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.
3896
+ * Falls back to the original URL on error, but only after a bounded download when a cap is set.
3890
3897
  *
3891
3898
  * Note: configureClient must be called before using this function.
3892
3899
  */
3893
- async function uploadImageFromUrl(imageUrl) {
3900
+ async function uploadImageFromUrl(imageUrl, maxBytes) {
3901
+ let sourceSizeVerified = false;
3894
3902
  try {
3895
3903
  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
- }
3904
+ if (url.protocol !== "http:" && url.protocol !== "https:") throw new Error("Tlon image URL must use HTTP or HTTPS");
3900
3905
  const fetched = await readRemoteMediaBuffer({
3901
3906
  url: imageUrl,
3902
- maxBytes: MAX_IMAGE_BYTES,
3907
+ maxBytes: Math.min(maxBytes ?? MAX_IMAGE_BYTES, MAX_IMAGE_BYTES),
3903
3908
  ...TLON_MEDIA_FETCH_TIMEOUTS,
3904
3909
  ssrfPolicy: void 0,
3905
3910
  requestInit: { method: "GET" }
3906
3911
  });
3912
+ sourceSizeVerified = true;
3907
3913
  const contentType = fetched.contentType || "image/png";
3908
3914
  return (await uploadFile({
3909
- blob: new Blob([new Uint8Array(fetched.buffer)], { type: contentType }),
3915
+ blob: new Blob([bufferToBlobPart(fetched.buffer)], { type: contentType }),
3910
3916
  fileName: new URL(imageUrl).pathname.split("/").pop() || `upload-${Date.now()}.png`,
3911
3917
  contentType
3912
3918
  })).url;
3913
3919
  } catch (err) {
3920
+ if (maxBytes !== void 0 && !sourceSizeVerified) throw err;
3914
3921
  console.warn(`[tlon] Failed to upload image, using original URL: ${String(err)}`);
3915
3922
  return imageUrl;
3916
3923
  }
@@ -3922,43 +3929,40 @@ async function createHttpPokeApi(params) {
3922
3929
  const cookie = await authenticate(params.url, params.code, { ssrfPolicy });
3923
3930
  const channelPath = `/~/channel/${`${Math.floor(Date.now() / 1e3)}-${crypto.randomUUID()}`}`;
3924
3931
  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])
3932
+ return { poke: async (pokeParams) => {
3933
+ const pokeId = Date.now();
3934
+ const pokeData = {
3935
+ id: pokeId,
3936
+ action: "poke",
3937
+ ship: shipName,
3938
+ app: pokeParams.app,
3939
+ mark: pokeParams.mark,
3940
+ json: pokeParams.json
3941
+ };
3942
+ const { response, release } = await urbitFetch({
3943
+ baseUrl: params.url,
3944
+ path: channelPath,
3945
+ init: {
3946
+ method: "PUT",
3947
+ headers: {
3948
+ "Content-Type": "application/json",
3949
+ Cookie: expectDefined(cookie.split(";").at(0), "cookie first segment")
3946
3950
  },
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();
3951
+ body: JSON.stringify([pokeData])
3952
+ },
3953
+ ssrfPolicy,
3954
+ auditContext: "tlon-poke"
3955
+ });
3956
+ try {
3957
+ if (!response.ok && response.status !== 204) {
3958
+ const errorText = await readResponseTextLimited(response, 16384);
3959
+ throw new Error(`Poke failed: ${response.status} - ${errorText}`);
3958
3960
  }
3959
- },
3960
- delete: async () => {}
3961
- };
3961
+ return pokeId;
3962
+ } finally {
3963
+ await release();
3964
+ }
3965
+ } };
3962
3966
  }
3963
3967
  function resolveOutboundContext(params) {
3964
3968
  const account = resolveTlonAccount(params.cfg, params.accountId ?? void 0);
@@ -3973,64 +3977,16 @@ function resolveOutboundContext(params) {
3973
3977
  function resolveReplyId(replyToId, threadId) {
3974
3978
  return replyToId ?? threadId ? String(replyToId ?? threadId) : void 0;
3975
3979
  }
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
3980
+ async function sendTlonOutbound(params, kind) {
3981
+ const { cfg, to, text, accountId, replyToId, threadId } = params;
3982
+ const { account, parsed } = resolveOutboundContext({
3983
+ cfg,
3984
+ accountId,
3985
+ to
3982
3986
  });
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
- });
3987
+ let uploadedUrl;
3988
+ if (kind === "media") {
3989
+ const { mediaUrl } = params;
4034
3990
  configureClient({
4035
3991
  shipUrl: account.url,
4036
3992
  shipName: account.ship.replace(/^~/, ""),
@@ -4038,28 +3994,36 @@ const tlonRuntimeOutbound = {
4038
3994
  getCode: async () => account.code,
4039
3995
  dangerouslyAllowPrivateNetwork: account.dangerouslyAllowPrivateNetwork ?? void 0
4040
3996
  });
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
- });
3997
+ uploadedUrl = mediaUrl ? await uploadImageFromUrl(mediaUrl, account.mediaMaxBytes) : void 0;
4062
3998
  }
3999
+ const api = await createHttpPokeApi({
4000
+ url: account.url,
4001
+ ship: account.ship,
4002
+ code: account.code,
4003
+ dangerouslyAllowPrivateNetwork: account.dangerouslyAllowPrivateNetwork ?? void 0
4004
+ });
4005
+ const fromShip = normalizeShip(account.ship);
4006
+ const story = kind === "media" ? buildMediaStory(text, uploadedUrl) : markdownToStory(text);
4007
+ if (parsed.kind === "dm") return await sendDmWithStory({
4008
+ api,
4009
+ fromShip,
4010
+ toShip: parsed.ship,
4011
+ story,
4012
+ kind
4013
+ });
4014
+ return await sendGroupMessageWithStory({
4015
+ api,
4016
+ fromShip,
4017
+ hostShip: parsed.hostShip,
4018
+ channelName: parsed.channelName,
4019
+ story,
4020
+ replyToId: resolveReplyId(replyToId, threadId),
4021
+ kind
4022
+ });
4023
+ }
4024
+ const tlonRuntimeOutbound = {
4025
+ sendText: (params) => sendTlonOutbound(params, "text"),
4026
+ sendMedia: (params) => sendTlonOutbound(params, "media")
4063
4027
  };
4064
4028
  async function probeTlonAccount(account, timeoutMs) {
4065
4029
  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.1",
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.1116.0",
12
+ "@aws-sdk/s3-request-presigner": "3.1116.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.1"
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.1"
124
124
  },
125
125
  "build": {
126
- "openclawVersion": "2026.9.1-beta.1"
126
+ "openclawVersion": "2026.9.1"
127
127
  },
128
128
  "release": {
129
129
  "bundleRuntimeDependencies": false,