@openclaw/tlon 2026.7.1 → 2026.7.2-beta.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
- 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-C5wXFh-q.js";
2
- import { t as tlonPlugin } from "./channel-DEy-ysbN.js";
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-B3c5Sud6.js";
3
3
  import { n as setTlonRuntime } from "./runtime-Ck3lNvST.js";
4
- export { SsrFBlockedError, createDedupeCache, createLoggerBackedRuntime, fetchWithSsrFGuard, isBlockedHostnameOrIp, setTlonRuntime, ssrfPolicyFromAllowPrivateNetwork, ssrfPolicyFromDangerouslyAllowPrivateNetwork, tlonPlugin };
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-DhzowRcD.js";
2
- import { a as tlonSetupAdapter, d as formatTargetHint, f as normalizeShip, h as resolveTlonOutboundTarget, l as listTlonAccountIds, m as parseTlonTarget, n as createTlonSetupWizardBase, u as resolveTlonAccount } from "./setup-core-C373Z5Vo.js";
2
+ import { a as tlonSetupAdapter, d as formatTargetHint, f as normalizeShip, h as resolveTlonOutboundTarget, l as listTlonAccountIds, m as parseTlonTarget, n as createTlonSetupWizardBase, u as resolveTlonAccount } from "./setup-core-BgykzCYT.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";
@@ -8,6 +8,7 @@ import { createChatChannelPlugin } from "openclaw/plugin-sdk/channel-core";
8
8
  import { createChannelMessageAdapterFromOutbound, createRuntimeOutboundDelegates } from "openclaw/plugin-sdk/channel-outbound";
9
9
  import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
10
10
  import { createComputedAccountStatusAdapter, createDefaultChannelRuntimeState } from "openclaw/plugin-sdk/status-helpers";
11
+ import { sanitizeAssistantVisibleText } from "openclaw/plugin-sdk/text-chunking";
11
12
  import { buildChannelConfigSchema } from "openclaw/plugin-sdk/channel-config-schema";
12
13
  import { z } from "zod";
13
14
  //#region extensions/tlon/src/config-schema.ts
@@ -86,7 +87,7 @@ function resolveTlonOutboundSessionRoute(params) {
86
87
  //#endregion
87
88
  //#region extensions/tlon/src/channel.ts
88
89
  const TLON_CHANNEL_ID = "tlon";
89
- const loadTlonChannelRuntime = createLazyRuntimeModule(() => import("./channel.runtime-jkmzax9d.js"));
90
+ const loadTlonChannelRuntime = createLazyRuntimeModule(() => import("./channel.runtime-BtBrqXGq.js"));
90
91
  const tlonSetupWizardProxy = createTlonSetupWizardBase({
91
92
  resolveConfigured: async ({ cfg, accountId }) => await (await loadTlonChannelRuntime()).tlonSetupWizard.status.resolveConfigured({
92
93
  cfg,
@@ -117,6 +118,7 @@ const tlonConfigAdapter = createHybridChannelConfigAdapter({
117
118
  const tlonChannelOutbound = {
118
119
  deliveryMode: "direct",
119
120
  textChunkLimit: 1e4,
121
+ sanitizeText: ({ text }) => sanitizeAssistantVisibleText(text),
120
122
  resolveTarget: ({ to }) => resolveTlonOutboundTarget(to),
121
123
  deliveryCapabilities: { durableFinal: {
122
124
  text: true,
@@ -1,2 +1,2 @@
1
- import { t as tlonPlugin } from "./channel-DEy-ysbN.js";
1
+ import { t as tlonPlugin } from "./channel-B3c5Sud6.js";
2
2
  export { tlonPlugin };
@@ -1,16 +1,18 @@
1
- import { n as createDedupeCache, s as createLoggerBackedRuntime } from "./runtime-api-C5wXFh-q.js";
2
- import { c as validateUrbitBaseUrl, d as formatTargetHint, f as normalizeShip, h as resolveTlonOutboundTarget, m as parseTlonTarget, p as parseChannelNest, s as normalizeUrbitHostname, u as resolveTlonAccount } from "./setup-core-C373Z5Vo.js";
1
+ import { n as createDedupeCache, o as createLoggerBackedRuntime } from "./runtime-api-BXVe40nS.js";
2
+ import { c as validateUrbitBaseUrl, d as formatTargetHint, f as normalizeShip, h as resolveTlonOutboundTarget, m as parseTlonTarget, p as parseChannelNest, s as normalizeUrbitHostname, u as resolveTlonAccount } from "./setup-core-BgykzCYT.js";
3
3
  import { t as getTlonRuntime } from "./runtime-Ck3lNvST.js";
4
- import { t as tlonSetupWizard } from "./setup-surface-B0C8wpts.js";
4
+ import { t as tlonSetupWizard } from "./setup-surface-j5Hrbts7.js";
5
5
  import { fetchWithSsrFGuard, ssrfPolicyFromDangerouslyAllowPrivateNetwork } from "openclaw/plugin-sdk/ssrf-runtime";
6
6
  import { createMessageReceiptFromOutboundResults } from "openclaw/plugin-sdk/channel-outbound";
7
+ import { expectDefined } from "openclaw/plugin-sdk/expect-runtime";
7
8
  import { asFiniteNumber, normalizeLowercaseStringOrEmpty, uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
8
9
  import crypto, { randomBytes, randomUUID } from "node:crypto";
10
+ import { readProviderJsonResponse, readResponseTextLimited } from "openclaw/plugin-sdk/provider-http";
11
+ import { sleepWithAbort } from "openclaw/plugin-sdk/runtime-env";
9
12
  import { sliceUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
10
13
  import { da, scot } from "@urbit/aura";
11
14
  import { Readable } from "node:stream";
12
15
  import { resolveTimerTimeoutMs } from "openclaw/plugin-sdk/number-runtime";
13
- import { readProviderJsonResponse, readResponseTextLimited } from "openclaw/plugin-sdk/provider-http";
14
16
  import { resolveStableChannelMessageIngress } from "openclaw/plugin-sdk/channel-ingress-runtime";
15
17
  import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
16
18
  import { mkdir, writeFile } from "node:fs/promises";
@@ -335,6 +337,11 @@ function getUrbitContext(url, ship) {
335
337
  //#endregion
336
338
  //#region extensions/tlon/src/urbit/story.ts
337
339
  /**
340
+ * Tlon Story Format - Rich text converter
341
+ *
342
+ * Converts markdown-like text to Tlon's story format.
343
+ */
344
+ /**
338
345
  * Parse inline markdown formatting (bold, italic, code, links, mentions)
339
346
  */
340
347
  function parseInlineMarkdown(text) {
@@ -343,41 +350,41 @@ function parseInlineMarkdown(text) {
343
350
  while (remaining.length > 0) {
344
351
  const shipMatch = remaining.match(/^(~[a-z][-a-z0-9]*)/);
345
352
  if (shipMatch) {
346
- result.push({ ship: shipMatch[1] });
353
+ result.push({ ship: expectDefined(shipMatch[1], "ship mention capture") });
347
354
  remaining = remaining.slice(shipMatch[0].length);
348
355
  continue;
349
356
  }
350
357
  const boldMatch = remaining.match(/^\*\*(.+?)\*\*|^__(.+?)__/);
351
358
  if (boldMatch) {
352
- const content = boldMatch[1] || boldMatch[2];
359
+ const content = expectDefined(boldMatch[1] ?? boldMatch[2], "bold body capture");
353
360
  result.push({ bold: parseInlineMarkdown(content) });
354
361
  remaining = remaining.slice(boldMatch[0].length);
355
362
  continue;
356
363
  }
357
364
  const italicsMatch = remaining.match(/^\*([^*]+?)\*|^_([^_]+?)_(?![a-zA-Z0-9])/);
358
365
  if (italicsMatch) {
359
- const content = italicsMatch[1] || italicsMatch[2];
366
+ const content = expectDefined(italicsMatch[1] ?? italicsMatch[2], "italic body capture");
360
367
  result.push({ italics: parseInlineMarkdown(content) });
361
368
  remaining = remaining.slice(italicsMatch[0].length);
362
369
  continue;
363
370
  }
364
371
  const strikeMatch = remaining.match(/^~~(.+?)~~/);
365
372
  if (strikeMatch) {
366
- result.push({ strike: parseInlineMarkdown(strikeMatch[1]) });
373
+ result.push({ strike: parseInlineMarkdown(expectDefined(strikeMatch[1], "strikethrough body capture")) });
367
374
  remaining = remaining.slice(strikeMatch[0].length);
368
375
  continue;
369
376
  }
370
377
  const codeMatch = remaining.match(/^`([^`]+)`/);
371
378
  if (codeMatch) {
372
- result.push({ "inline-code": codeMatch[1] });
379
+ result.push({ "inline-code": expectDefined(codeMatch[1], "inline code capture") });
373
380
  remaining = remaining.slice(codeMatch[0].length);
374
381
  continue;
375
382
  }
376
383
  const linkMatch = remaining.match(/^\[([^\]]+)\]\(([^)]+)\)/);
377
384
  if (linkMatch) {
378
385
  result.push({ link: {
379
- href: linkMatch[2],
380
- content: linkMatch[1]
386
+ href: expectDefined(linkMatch[2], "link URL capture"),
387
+ content: expectDefined(linkMatch[1], "link text capture")
381
388
  } });
382
389
  remaining = remaining.slice(linkMatch[0].length);
383
390
  continue;
@@ -385,39 +392,53 @@ function parseInlineMarkdown(text) {
385
392
  const imageMatch = remaining.match(/^!\[([^\]]*)\]\(([^)]+)\)/);
386
393
  if (imageMatch) {
387
394
  result.push({ __image: {
388
- src: imageMatch[2],
389
- alt: imageMatch[1]
395
+ src: expectDefined(imageMatch[2], "image URL capture"),
396
+ alt: expectDefined(imageMatch[1], "image alt capture")
390
397
  } });
391
398
  remaining = remaining.slice(imageMatch[0].length);
392
399
  continue;
393
400
  }
394
401
  const urlMatch = remaining.match(/^(https?:\/\/[^\s<>"\]]+)/);
395
402
  if (urlMatch) {
403
+ const url = expectDefined(urlMatch[1], "plain URL capture");
396
404
  result.push({ link: {
397
- href: urlMatch[1],
398
- content: urlMatch[1]
405
+ href: url,
406
+ content: url
399
407
  } });
400
408
  remaining = remaining.slice(urlMatch[0].length);
401
409
  continue;
402
410
  }
403
411
  const plainMatch = remaining.match(/^[^*_`~[#\n:/]+/);
404
412
  if (plainMatch) {
405
- result.push(plainMatch[0]);
413
+ result.push(expectDefined(plainMatch[0], "plain text match"));
406
414
  remaining = remaining.slice(plainMatch[0].length);
407
415
  continue;
408
416
  }
409
- result.push(remaining[0]);
417
+ result.push(remaining.charAt(0));
410
418
  remaining = remaining.slice(1);
411
419
  }
412
420
  return mergeAdjacentStrings(result);
413
421
  }
422
+ function headingTag(marker) {
423
+ switch (marker.length) {
424
+ case 1: return "h1";
425
+ case 2: return "h2";
426
+ case 3: return "h3";
427
+ case 4: return "h4";
428
+ case 5: return "h5";
429
+ default: return "h6";
430
+ }
431
+ }
414
432
  /**
415
433
  * Merge adjacent string elements in an inline array
416
434
  */
417
435
  function mergeAdjacentStrings(inlines) {
418
436
  const result = [];
419
- for (const item of inlines) if (typeof item === "string" && typeof result[result.length - 1] === "string") result[result.length - 1] = result[result.length - 1] + item;
420
- else result.push(item);
437
+ for (const item of inlines) {
438
+ const last = result.at(-1);
439
+ if (typeof item === "string" && typeof last === "string") result.splice(-1, 1, last + item);
440
+ else result.push(item);
441
+ }
421
442
  return result;
422
443
  }
423
444
  /**
@@ -435,7 +456,12 @@ function createImageBlock(src, alt = "", height = 0, width = 0) {
435
456
  * Check if URL looks like an image
436
457
  */
437
458
  function isImageUrl(url) {
438
- return /\.(jpg|jpeg|png|gif|webp|svg|bmp|ico)(\?.*)?$/i.test(url);
459
+ const imageExtensions = /\.(jpg|jpeg|png|gif|webp|svg|bmp|ico)$/i;
460
+ let path = url.split(/[?#]/, 1)[0] ?? url;
461
+ try {
462
+ path = new URL(url).pathname;
463
+ } catch {}
464
+ return imageExtensions.test(path);
439
465
  }
440
466
  /**
441
467
  * Process inlines and extract any image markers into blocks
@@ -460,13 +486,15 @@ function markdownToStory(markdown) {
460
486
  const lines = markdown.split("\n");
461
487
  let i = 0;
462
488
  while (i < lines.length) {
463
- const line = lines[i];
489
+ const line = expectDefined(lines[i], "Markdown line index is in bounds");
464
490
  if (line.startsWith("```")) {
465
491
  const lang = line.slice(3).trim() || "plaintext";
466
492
  const codeLines = [];
467
493
  i++;
468
- while (i < lines.length && !lines[i].startsWith("```")) {
469
- codeLines.push(lines[i]);
494
+ while (true) {
495
+ const codeLine = lines.at(i);
496
+ if (codeLine === void 0 || codeLine.startsWith("```")) break;
497
+ codeLines.push(codeLine);
470
498
  i++;
471
499
  }
472
500
  story.push({ block: { code: {
@@ -478,10 +506,10 @@ function markdownToStory(markdown) {
478
506
  }
479
507
  const headerMatch = line.match(/^(#{1,6})\s+(.+)$/);
480
508
  if (headerMatch) {
481
- const tag = `h${headerMatch[1].length}`;
509
+ const tag = headingTag(expectDefined(headerMatch[1], "header marker capture"));
482
510
  story.push({ block: { header: {
483
511
  tag,
484
- content: parseInlineMarkdown(headerMatch[2])
512
+ content: parseInlineMarkdown(expectDefined(headerMatch[2], "header body capture"))
485
513
  } } });
486
514
  i++;
487
515
  continue;
@@ -493,8 +521,10 @@ function markdownToStory(markdown) {
493
521
  }
494
522
  if (line.startsWith("> ")) {
495
523
  const quoteLines = [];
496
- while (i < lines.length && lines[i].startsWith("> ")) {
497
- quoteLines.push(lines[i].slice(2));
524
+ while (true) {
525
+ const quoteLine = lines.at(i);
526
+ if (quoteLine === void 0 || !quoteLine.startsWith("> ")) break;
527
+ quoteLines.push(quoteLine.slice(2));
498
528
  i++;
499
529
  }
500
530
  const quoteText = quoteLines.join("\n");
@@ -506,8 +536,10 @@ function markdownToStory(markdown) {
506
536
  continue;
507
537
  }
508
538
  const paragraphLines = [];
509
- while (i < lines.length && lines[i].trim() !== "" && !lines[i].startsWith("#") && !lines[i].startsWith("```") && !lines[i].startsWith("> ") && !/^(-{3,}|\*{3,})$/.test(lines[i].trim())) {
510
- paragraphLines.push(lines[i]);
539
+ while (true) {
540
+ const paragraphLine = lines.at(i);
541
+ if (paragraphLine === void 0 || paragraphLine.trim() === "" || paragraphLine.startsWith("#") || paragraphLine.startsWith("```") || paragraphLine.startsWith("> ") || /^(-{3,}|\*{3,})$/.test(paragraphLine.trim())) break;
542
+ paragraphLines.push(paragraphLine);
511
543
  i++;
512
544
  }
513
545
  if (paragraphLines.length > 0) {
@@ -515,8 +547,8 @@ function markdownToStory(markdown) {
515
547
  const withBreaks = [];
516
548
  for (const inline of inlines) if (typeof inline === "string" && inline.includes("\n")) {
517
549
  const parts = inline.split("\n");
518
- for (let j = 0; j < parts.length; j++) {
519
- if (parts[j]) withBreaks.push(parts[j]);
550
+ for (const [j, part] of parts.entries()) {
551
+ if (part) withBreaks.push(part);
520
552
  if (j < parts.length - 1) withBreaks.push({ break: null });
521
553
  }
522
554
  } else withBreaks.push(inline);
@@ -756,7 +788,9 @@ async function ensureUrbitChannelOpen(deps, params) {
756
788
  }
757
789
  //#endregion
758
790
  //#region extensions/tlon/src/urbit/sse-client.ts
791
+ const MAX_SSE_PAYLOAD_BYTES = 16 * 1024 * 1024;
759
792
  function parseUrbitSsePayload(data) {
793
+ if (Buffer.byteLength(data, "utf8") > MAX_SSE_PAYLOAD_BYTES) throw new Error("Tlon Urbit SSE payload exceeds 16 MiB limit");
760
794
  try {
761
795
  return JSON.parse(data);
762
796
  } catch (cause) {
@@ -857,51 +891,92 @@ var UrbitSSEClient = class {
857
891
  const controller = new AbortController();
858
892
  const timeoutId = setTimeout(() => controller.abort(), 6e4);
859
893
  this.streamController = controller;
860
- const { response, release } = await urbitFetch({
861
- baseUrl: this.url,
862
- path: `/~/channel/${this.channelId}`,
863
- init: {
864
- method: "GET",
865
- headers: {
866
- Accept: "text/event-stream",
867
- Cookie: this.cookie
868
- }
869
- },
870
- ssrfPolicy: this.ssrfPolicy,
871
- lookupFn: this.lookupFn,
872
- fetchImpl: this.fetchImpl,
873
- signal: controller.signal,
874
- auditContext: "tlon-urbit-sse-stream"
875
- });
894
+ let stream;
895
+ try {
896
+ stream = await urbitFetch({
897
+ baseUrl: this.url,
898
+ path: `/~/channel/${this.channelId}`,
899
+ init: {
900
+ method: "GET",
901
+ headers: {
902
+ Accept: "text/event-stream",
903
+ Cookie: this.cookie
904
+ }
905
+ },
906
+ ssrfPolicy: this.ssrfPolicy,
907
+ lookupFn: this.lookupFn,
908
+ fetchImpl: this.fetchImpl,
909
+ signal: controller.signal,
910
+ auditContext: "tlon-urbit-sse-stream"
911
+ });
912
+ } finally {
913
+ clearTimeout(timeoutId);
914
+ }
915
+ const { response, release } = stream;
876
916
  this.streamRelease = release;
877
- clearTimeout(timeoutId);
878
917
  if (!response.ok) {
879
- await release();
880
918
  this.streamRelease = null;
919
+ await release();
881
920
  throw new Error(`Stream connection failed: ${response.status}`);
882
921
  }
883
922
  this.processStream(response.body).catch((error) => {
884
923
  if (!this.aborted) {
885
924
  this.logger.error?.(`Stream error: ${String(error)}`);
886
- for (const { err } of this.eventHandlers.values()) if (err) err(error);
925
+ for (const { err } of this.eventHandlers.values()) err?.(error);
887
926
  }
888
927
  });
889
928
  }
890
929
  async processStream(body) {
891
930
  if (!body) return;
892
931
  const stream = body instanceof ReadableStream ? Readable.fromWeb(body) : body;
932
+ const decoder = new TextDecoder();
893
933
  let buffer = "";
934
+ let bufferBytes = 0;
935
+ let pendingDelimiterNewline = false;
936
+ const appendPending = (text) => {
937
+ const previousCodeUnit = buffer.charCodeAt(buffer.length - 1);
938
+ const firstCodeUnit = text.charCodeAt(0);
939
+ const joinsSurrogatePair = previousCodeUnit >= 55296 && previousCodeUnit <= 56319 && firstCodeUnit >= 56320 && firstCodeUnit <= 57343;
940
+ const nextBytes = bufferBytes + Buffer.byteLength(text, "utf8") - (joinsSurrogatePair ? 2 : 0);
941
+ if (nextBytes > MAX_SSE_PAYLOAD_BYTES) throw new Error("Tlon Urbit SSE stream buffer exceeded 16 MiB limit");
942
+ buffer += text;
943
+ bufferBytes = nextBytes;
944
+ };
945
+ const consumeText = (text) => {
946
+ let offset = 0;
947
+ if (pendingDelimiterNewline && text.length > 0) {
948
+ pendingDelimiterNewline = false;
949
+ if (text.startsWith("\n")) {
950
+ this.processEvent(buffer);
951
+ buffer = "";
952
+ bufferBytes = 0;
953
+ offset = 1;
954
+ } else appendPending("\n");
955
+ }
956
+ while (offset < text.length) {
957
+ const eventEnd = text.indexOf("\n\n", offset);
958
+ if (eventEnd === -1) {
959
+ const endsWithNewline = text.endsWith("\n");
960
+ appendPending(text.slice(offset, endsWithNewline ? -1 : void 0));
961
+ pendingDelimiterNewline = endsWithNewline;
962
+ return;
963
+ }
964
+ appendPending(text.slice(offset, eventEnd));
965
+ this.processEvent(buffer);
966
+ buffer = "";
967
+ bufferBytes = 0;
968
+ offset = eventEnd + 2;
969
+ }
970
+ };
894
971
  try {
895
972
  for await (const chunk of stream) {
896
973
  if (this.aborted) break;
897
- buffer += chunk.toString();
898
- let eventEnd;
899
- while ((eventEnd = buffer.indexOf("\n\n")) !== -1) {
900
- const eventData = buffer.slice(0, eventEnd);
901
- buffer = buffer.slice(eventEnd + 2);
902
- this.processEvent(eventData);
903
- }
974
+ if (typeof chunk === "string") {
975
+ consumeText(decoder.decode());
976
+ consumeText(chunk);
977
+ } else consumeText(decoder.decode(chunk, { stream: true }));
904
978
  }
979
+ consumeText(decoder.decode());
905
980
  } finally {
906
981
  if (this.streamRelease) {
907
982
  const release = this.streamRelease;
@@ -1215,7 +1290,7 @@ function parseAdminCommand(text) {
1215
1290
  const unblockMatch = trimmed.match(/^unblock\s+(~[\w-]+)$/);
1216
1291
  if (unblockMatch) return {
1217
1292
  type: "unblock",
1218
- ship: unblockMatch[1]
1293
+ ship: expectDefined(unblockMatch[1], "unblock ship capture")
1219
1294
  };
1220
1295
  return null;
1221
1296
  }
@@ -1389,7 +1464,7 @@ function createTlonApprovalRuntime(params) {
1389
1464
  const approvals = getPendingApprovals();
1390
1465
  const existingIndex = approvals.findIndex((item) => item.type === approval.type && item.requestingShip === approval.requestingShip && (approval.type !== "channel" || item.channelNest === approval.channelNest) && (approval.type !== "group" || item.groupFlag === approval.groupFlag));
1391
1466
  if (existingIndex !== -1) {
1392
- const existing = approvals[existingIndex];
1467
+ const existing = expectDefined(approvals[existingIndex], "located pending approval index");
1393
1468
  if (approval.originalMessage) {
1394
1469
  existing.originalMessage = approval.originalMessage;
1395
1470
  existing.messagePreview = approval.messagePreview;
@@ -1547,8 +1622,8 @@ function extractCites(content) {
1547
1622
  }
1548
1623
  function formatModelName(modelString) {
1549
1624
  if (!modelString) return "AI";
1550
- const modelName = modelString.includes("/") ? modelString.split("/")[1] : modelString;
1551
- const modelMappings = {
1625
+ const modelName = modelString.includes("/") ? expectDefined(modelString.split("/").at(1), "provider/model second segment") : modelString;
1626
+ const mappedName = {
1552
1627
  "claude-opus-4-5": "Claude Opus 4.5",
1553
1628
  "claude-sonnet-4-5": "Claude Sonnet 4.5",
1554
1629
  "claude-sonnet-3-5": "Claude Sonnet 3.5",
@@ -1557,8 +1632,8 @@ function formatModelName(modelString) {
1557
1632
  "gpt-4": "GPT-4",
1558
1633
  "gemini-2.0-flash": "Gemini 2.0 Flash",
1559
1634
  "gemini-pro": "Gemini Pro"
1560
- };
1561
- if (modelMappings[modelName]) return modelMappings[modelName];
1635
+ }[modelName];
1636
+ if (mappedName !== void 0) return mappedName;
1562
1637
  return modelName.replace(/-/g, " ").split(" ").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
1563
1638
  }
1564
1639
  function isBotMentioned(messageText, botShipName, nickname) {
@@ -1941,9 +2016,14 @@ async function fetchThreadHistory(api, channelNest, parentId, count = 50, runtim
1941
2016
  }
1942
2017
  }
1943
2018
  //#endregion
2019
+ //#region extensions/tlon/src/media-fetch-timeouts.ts
2020
+ const TLON_MEDIA_FETCH_TIMEOUTS = {
2021
+ responseHeaderTimeoutMs: 12e4,
2022
+ readIdleTimeoutMs: 3e4
2023
+ };
2024
+ //#endregion
1944
2025
  //#region extensions/tlon/src/monitor/media.ts
1945
2026
  const MAX_IMAGES_PER_MESSAGE = 8;
1946
- const TLON_MEDIA_DOWNLOAD_IDLE_TIMEOUT_MS = 3e4;
1947
2027
  /**
1948
2028
  * Extract image blocks from Tlon message content.
1949
2029
  * Returns array of image URLs found in the message.
@@ -1974,7 +2054,7 @@ async function downloadMedia(url, mediaDir) {
1974
2054
  const fetchOptions = {
1975
2055
  url,
1976
2056
  maxBytes: MAX_IMAGE_BYTES,
1977
- readIdleTimeoutMs: TLON_MEDIA_DOWNLOAD_IDLE_TIMEOUT_MS,
2057
+ ...TLON_MEDIA_FETCH_TIMEOUTS,
1978
2058
  ssrfPolicy: void 0,
1979
2059
  requestInit: { method: "GET" }
1980
2060
  };
@@ -2226,16 +2306,7 @@ async function monitorTlonProvider(opts = {}) {
2226
2306
  if (attempt >= maxAttempts) throw error;
2227
2307
  const delay = Math.min(3e4, 1e3 * 2 ** (attempt - 1));
2228
2308
  runtime.log?.(`[tlon] Retrying authentication in ${delay}ms...`);
2229
- await new Promise((resolve, reject) => {
2230
- const timer = setTimeout(resolve, delay);
2231
- if (opts.abortSignal) {
2232
- const onAbort = () => {
2233
- clearTimeout(timer);
2234
- reject(/* @__PURE__ */ new Error("Aborted"));
2235
- };
2236
- opts.abortSignal.addEventListener("abort", onAbort, { once: true });
2237
- }
2238
- });
2309
+ await sleepWithAbort(delay, opts.abortSignal);
2239
2310
  }
2240
2311
  }
2241
2312
  throw new Error("unreachable Tlon authentication retry loop exit");
@@ -3187,6 +3258,10 @@ async function monitorTlonProvider(opts = {}) {
3187
3258
  const MEMEX_BASE_URL = "https://memex.tlon.network";
3188
3259
  /** Max bytes to read from the Memex upload JSON response. */
3189
3260
  const MEMEX_UPLOAD_RESPONSE_MAX_BYTES = 64 * 1024;
3261
+ /** Total deadline for the Memex upload URL lookup, including DNS and response reading. */
3262
+ const TLON_MEMEX_UPLOAD_URL_TIMEOUT_MS = 3e4;
3263
+ /** Total deadline for Memex and custom S3 PUTs, including DNS and the full upload. */
3264
+ const TLON_UPLOAD_TIMEOUT_MS = 3e5;
3190
3265
  let currentClientConfig = null;
3191
3266
  function configureClient(params) {
3192
3267
  currentClientConfig = {
@@ -3303,7 +3378,8 @@ async function getMemexUploadUrl(params) {
3303
3378
  },
3304
3379
  auditContext: "tlon-memex-upload-url",
3305
3380
  capture: false,
3306
- maxRedirects: 0
3381
+ maxRedirects: 0,
3382
+ timeoutMs: TLON_MEMEX_UPLOAD_URL_TIMEOUT_MS
3307
3383
  });
3308
3384
  release = guarded.release;
3309
3385
  if (!guarded.response.ok) throw new Error(`Memex upload request failed: ${guarded.response.status}`);
@@ -3349,7 +3425,8 @@ async function uploadFile(params) {
3349
3425
  },
3350
3426
  auditContext: "tlon-memex-upload",
3351
3427
  capture: false,
3352
- maxRedirects: 0
3428
+ maxRedirects: 0,
3429
+ timeoutMs: TLON_UPLOAD_TIMEOUT_MS
3353
3430
  });
3354
3431
  release = guarded.release;
3355
3432
  assertTrustedMemexUploadUrl(guarded.finalUrl, "Memex final upload URL");
@@ -3360,13 +3437,8 @@ async function uploadFile(params) {
3360
3437
  return { url: assertTrustedMemexUploadUrl(hostedUrl, "Memex hosted URL") };
3361
3438
  }
3362
3439
  if (!hasCustomS3Creds(credentials)) throw new Error("No storage credentials configured");
3363
- const endpoint = new URL(prefixEndpoint(credentials.endpoint));
3364
3440
  const client = new S3Client({
3365
- endpoint: {
3366
- protocol: endpoint.protocol.slice(0, -1),
3367
- hostname: endpoint.host,
3368
- path: endpoint.pathname || "/"
3369
- },
3441
+ endpoint: prefixEndpoint(credentials.endpoint),
3370
3442
  region: storageConfig.region || "us-east-1",
3371
3443
  credentials: {
3372
3444
  accessKeyId: credentials.accessKeyId,
@@ -3385,10 +3457,7 @@ async function uploadFile(params) {
3385
3457
  ContentType: headers["Content-Type"],
3386
3458
  CacheControl: headers["Cache-Control"],
3387
3459
  ACL: "public-read"
3388
- }), {
3389
- expiresIn: 3600,
3390
- signableHeaders: new Set(Object.keys(headers))
3391
- });
3460
+ }), { expiresIn: 3600 });
3392
3461
  let release;
3393
3462
  try {
3394
3463
  const guarded = await fetchWithSsrFGuard({
@@ -3401,21 +3470,21 @@ async function uploadFile(params) {
3401
3470
  auditContext: "tlon-custom-s3-upload",
3402
3471
  capture: false,
3403
3472
  maxRedirects: 0,
3404
- policy: privateNetworkPolicy
3473
+ policy: privateNetworkPolicy,
3474
+ timeoutMs: TLON_UPLOAD_TIMEOUT_MS
3405
3475
  });
3406
3476
  release = guarded.release;
3407
3477
  if (!guarded.response.ok) throw new Error(`Upload failed: ${guarded.response.status}`);
3408
3478
  } finally {
3409
3479
  await release?.();
3410
3480
  }
3411
- return { url: assertSafeUploadResultUrl(storageConfig.publicUrlBase ? new URL(fileKey, storageConfig.publicUrlBase).toString() : signedUrl.split("?")[0], "Upload result URL") };
3481
+ return { url: assertSafeUploadResultUrl(storageConfig.publicUrlBase ? new URL(fileKey, storageConfig.publicUrlBase).toString() : expectDefined(signedUrl.split("?").at(0), "signed URL base segment"), "Upload result URL") };
3412
3482
  }
3413
3483
  //#endregion
3414
3484
  //#region extensions/tlon/src/urbit/upload.ts
3415
3485
  /**
3416
3486
  * Upload an image from a URL to Tlon storage.
3417
3487
  */
3418
- const TLON_UPLOAD_IMAGE_IDLE_TIMEOUT_MS = 3e4;
3419
3488
  /**
3420
3489
  * Fetch an image from a URL and upload it to Tlon storage.
3421
3490
  * Returns the uploaded URL, or falls back to the original URL on error.
@@ -3432,7 +3501,7 @@ async function uploadImageFromUrl(imageUrl) {
3432
3501
  const fetched = await readRemoteMediaBuffer({
3433
3502
  url: imageUrl,
3434
3503
  maxBytes: MAX_IMAGE_BYTES,
3435
- readIdleTimeoutMs: TLON_UPLOAD_IMAGE_IDLE_TIMEOUT_MS,
3504
+ ...TLON_MEDIA_FETCH_TIMEOUTS,
3436
3505
  ssrfPolicy: void 0,
3437
3506
  requestInit: { method: "GET" }
3438
3507
  });
@@ -3472,7 +3541,7 @@ async function createHttpPokeApi(params) {
3472
3541
  method: "PUT",
3473
3542
  headers: {
3474
3543
  "Content-Type": "application/json",
3475
- Cookie: cookie.split(";")[0]
3544
+ Cookie: expectDefined(cookie.split(";").at(0), "cookie first segment")
3476
3545
  },
3477
3546
  body: JSON.stringify([pokeData])
3478
3547
  },
@@ -0,0 +1,4 @@
1
+ import { createDedupeCache } from "openclaw/plugin-sdk/core";
2
+ import { createLoggerBackedRuntime } from "openclaw/plugin-sdk/runtime";
3
+ import { SsrFBlockedError, fetchWithSsrFGuard as fetchWithSsrFGuard$1, isBlockedHostnameOrIp as isBlockedHostnameOrIp$1, ssrfPolicyFromDangerouslyAllowPrivateNetwork } from "openclaw/plugin-sdk/ssrf-runtime";
4
+ export { ssrfPolicyFromDangerouslyAllowPrivateNetwork as a, isBlockedHostnameOrIp$1 as i, createDedupeCache as n, createLoggerBackedRuntime as o, fetchWithSsrFGuard$1 as r, SsrFBlockedError as t };
@@ -1,2 +1,2 @@
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-C5wXFh-q.js";
2
- export { SsrFBlockedError, createDedupeCache, createLoggerBackedRuntime, fetchWithSsrFGuard, isBlockedHostnameOrIp, ssrfPolicyFromAllowPrivateNetwork, ssrfPolicyFromDangerouslyAllowPrivateNetwork };
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
+ export { SsrFBlockedError, createDedupeCache, createLoggerBackedRuntime, fetchWithSsrFGuard, isBlockedHostnameOrIp, ssrfPolicyFromDangerouslyAllowPrivateNetwork };
package/dist/setup-api.js CHANGED
@@ -1,3 +1,3 @@
1
- import { a as tlonSetupAdapter } from "./setup-core-C373Z5Vo.js";
2
- import { t as tlonSetupWizard } from "./setup-surface-B0C8wpts.js";
1
+ import { a as tlonSetupAdapter } from "./setup-core-BgykzCYT.js";
2
+ import { t as tlonSetupWizard } from "./setup-surface-j5Hrbts7.js";
3
3
  export { tlonSetupAdapter, tlonSetupWizard };
@@ -1,4 +1,5 @@
1
1
  import { hasLegacyFlatAllowPrivateNetworkAlias, isBlockedHostnameOrIp, isPrivateNetworkOptInEnabled } from "openclaw/plugin-sdk/ssrf-runtime";
2
+ import { expectDefined } from "openclaw/plugin-sdk/expect-runtime";
2
3
  import { DEFAULT_ACCOUNT_ID, createSetupInputPresenceValidator, createSetupTranslator, formatDocsLink, normalizeAccountId, patchScopedAccountConfig, prepareScopedSetupConfig } from "openclaw/plugin-sdk/setup";
3
4
  import { normalizeOptionalString, normalizeStringifiedOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
4
5
  import { DEFAULT_ACCOUNT_ID as DEFAULT_ACCOUNT_ID$1, listCombinedAccountIds, normalizeAccountId as normalizeAccountId$1, resolveMergedAccountConfig } from "openclaw/plugin-sdk/account-resolution";
@@ -14,8 +15,8 @@ function parseChannelNest(raw) {
14
15
  const match = NEST_RE.exec(raw.trim());
15
16
  if (!match) return null;
16
17
  return {
17
- hostShip: normalizeShip(match[1]),
18
- channelName: match[2]
18
+ hostShip: normalizeShip(expectDefined(match[1], "channel host capture")),
19
+ channelName: expectDefined(match[2], "channel name capture")
19
20
  };
20
21
  }
21
22
  function makeGroupTarget(parsed) {
@@ -33,11 +34,11 @@ function parseTlonTarget(raw) {
33
34
  const dmPrefix = withoutPrefix.match(/^dm[/:](.+)$/i);
34
35
  if (dmPrefix) return {
35
36
  kind: "dm",
36
- ship: normalizeShip(dmPrefix[1])
37
+ ship: normalizeShip(expectDefined(dmPrefix[1], "DM ship capture"))
37
38
  };
38
39
  const groupPrefix = withoutPrefix.match(/^(group|room)[/:](.+)$/i);
39
40
  if (groupPrefix) {
40
- const groupTarget = groupPrefix[2].trim();
41
+ const groupTarget = expectDefined(groupPrefix[2], "group target capture").trim();
41
42
  if (groupTarget.startsWith("chat/")) {
42
43
  const parsed = parseChannelNest(groupTarget);
43
44
  if (!parsed) return null;
@@ -45,8 +46,8 @@ function parseTlonTarget(raw) {
45
46
  }
46
47
  const parts = groupTarget.split("/");
47
48
  if (parts.length === 2) {
48
- const hostShip = normalizeShip(parts[0]);
49
- const channelName = parts[1];
49
+ const hostShip = normalizeShip(expectDefined(parts[0], "two-part group host"));
50
+ const channelName = expectDefined(parts[1], "two-part group channel");
50
51
  return {
51
52
  kind: "group",
52
53
  nest: `chat/${hostShip}/${channelName}`,
@@ -1,4 +1,4 @@
1
- import { c as validateUrbitBaseUrl, f as normalizeShip, i as resolveTlonSetupStatusLines, n as createTlonSetupWizardBase, o as isBlockedUrbitHostname, r as resolveTlonSetupConfigured, t as applyTlonSetupConfig, u as resolveTlonAccount } from "./setup-core-C373Z5Vo.js";
1
+ import { c as validateUrbitBaseUrl, f as normalizeShip, i as resolveTlonSetupStatusLines, n as createTlonSetupWizardBase, o as isBlockedUrbitHostname, r as resolveTlonSetupConfigured, t as applyTlonSetupConfig, u as resolveTlonAccount } from "./setup-core-BgykzCYT.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
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@openclaw/tlon",
3
- "version": "2026.7.1",
3
+ "version": "2026.7.2-beta.2",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@openclaw/tlon",
9
- "version": "2026.7.1",
9
+ "version": "2026.7.2-beta.2",
10
10
  "dependencies": {
11
11
  "@aws-sdk/client-s3": "3.1078.0",
12
12
  "@aws-sdk/s3-request-presigner": "3.1078.0",
@@ -15,7 +15,7 @@
15
15
  "zod": "4.4.3"
16
16
  },
17
17
  "peerDependencies": {
18
- "openclaw": ">=2026.7.1"
18
+ "openclaw": ">=2026.7.2-beta.2"
19
19
  },
20
20
  "peerDependenciesMeta": {
21
21
  "openclaw": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/tlon",
3
- "version": "2026.7.1",
3
+ "version": "2026.7.2-beta.2",
4
4
  "description": "OpenClaw Tlon/Urbit channel plugin for chat workflows.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -19,7 +19,7 @@
19
19
  "openclaw": "workspace:*"
20
20
  },
21
21
  "peerDependencies": {
22
- "openclaw": ">=2026.7.1"
22
+ "openclaw": ">=2026.7.2-beta.2"
23
23
  },
24
24
  "peerDependenciesMeta": {
25
25
  "openclaw": {
@@ -73,10 +73,10 @@
73
73
  "minHostVersion": ">=2026.4.10"
74
74
  },
75
75
  "compat": {
76
- "pluginApi": ">=2026.7.1"
76
+ "pluginApi": ">=2026.7.2-beta.2"
77
77
  },
78
78
  "build": {
79
- "openclawVersion": "2026.7.1"
79
+ "openclawVersion": "2026.7.2-beta.2"
80
80
  },
81
81
  "release": {
82
82
  "bundleRuntimeDependencies": false,
@@ -1,4 +0,0 @@
1
- import { createDedupeCache } from "openclaw/plugin-sdk/core";
2
- import { createLoggerBackedRuntime } from "openclaw/plugin-sdk/runtime";
3
- import { SsrFBlockedError, fetchWithSsrFGuard as fetchWithSsrFGuard$1, isBlockedHostnameOrIp as isBlockedHostnameOrIp$1, ssrfPolicyFromAllowPrivateNetwork, ssrfPolicyFromDangerouslyAllowPrivateNetwork } from "openclaw/plugin-sdk/ssrf-runtime";
4
- export { ssrfPolicyFromAllowPrivateNetwork as a, isBlockedHostnameOrIp$1 as i, createDedupeCache as n, ssrfPolicyFromDangerouslyAllowPrivateNetwork as o, fetchWithSsrFGuard$1 as r, createLoggerBackedRuntime as s, SsrFBlockedError as t };